// import data
use "data_sudan_aan25_militias_neg.dta", clear

tsset DyadId_old t 

// with all variables /// main model ///
logit inpp Mil_vs_Reb_dm_lag Mil_vs_Civ_lag Mil_vs_Gov_lag Mil_vs_Reb_oth_lag Mil_vs_Mil_lag duration_ln gbrd_best_cumsum_lag gbrd_best_lag rebno_ct tslinpp tslinpp2 tslinpp3, robust cluster(DyadId_old)
estat ic
mat es_ic = r(S)
local LL: display %4.1f es_ic[1,3]
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
est store m1
outreg2 m1 using table_sudans_appendix.doc, alpha(0.001, 0.01, 0.05, 0.10) symbol(***, **, *, +) stats(coef se) dec(2) addstat(LL, `LL', AIC, `AIC', BIC, `BIC') replace label sideway 


// Graph:
margins, at(Mil_vs_Reb_dm_lag =(0 (1) 20) Mil_vs_Civ_lag = 0  Mil_vs_Gov_lag = 0  ) 
marginsplot , recast(line) ciopt(color(%20)) recastci(rarea) graphregion(color(white)) title("") ytitle("") xtitle("Against Rebels (t-1)", size(small)) yscale(range(0 (0.1) 0.8 )) ylabel(0 [0.1] 0.8 ) name(g1, replace) xlabel(0 [5] 20, labsize(vsmall)) 


margins, at(Mil_vs_Civ_lag =(0 (1) 20) Mil_vs_Reb_dm_lag = 0  Mil_vs_Gov_lag = 0  ) 
marginsplot , recast(line) ciopt(color(%20)) recastci(rarea) graphregion(color(white)) title("") ytitle("") xtitle("Against Civilians (t-1)", size(small)) yscale(range(0 (0.1) 0.8 )) ylabel(0 [0.1] 0.8 ) name(g2, replace) xlabel(0 [5] 20, labsize(vsmall)) 

margins, at(Mil_vs_Gov_lag =(0 (1) 20) Mil_vs_Reb_dm_lag = 0  Mil_vs_Civ_lag = 0  ) 
marginsplot , recast(line) ciopt(color(%20)) recastci(rarea) graphregion(color(white)) title("") ytitle("") xtitle("Against Government (t-1)", size(small)) yscale(range(0 (0.1) 0.8 )) ylabel(0 [0.1] 0.8 ) name(g3, replace) xlabel(0 [5] 20, labsize(vsmall)) 

gr combine g1 g2 g3, col (3) l1(Pr(Negotiation)) t1(Militia Activity in Sudan and South Sudan) graphregion(color(white))
